
cc.Class({
  extends: cc.Component,

  properties: {
    playerRank: {
      default: null,
      type: cc.Label
    },
    playerHeadIcon: {
      default: null,
      type: cc.Sprite
    },
    playerName: {
      default: null,
      type: cc.Label
    },
    baseScorePlayer: {
      default: null,
      type: cc.Label
    },
  },

  onLoad: function () {
    this.playerRank.string = "0";
    this.playerName.string = "name";
    this.baseScorePlayer.string = "0";
  },

  update: function (dt) {
  },

  updateBaseScore: function (scoreReply ){
    var self = this;
    this.playerRank.string = scoreReply.rank;
    this.playerName.string = scoreReply.nickName;
    this.baseScorePlayer.string = scoreReply.score;

    if (scoreReply.avatarURL != null && scoreReply.avatarURL != "") {
      cc.loader.load({ url: scoreReply.avatarURL, type: 'jpg' }, function (err, texture) {
        // Use texture to create sprite frame
        if (err) {
          // cc.tool.msgBox.addMsg(err)
          console.error("头像err : " + err)
        } else {
          var s = new cc.SpriteFrame(texture);
          self.playerHeadIcon.spriteFrame = s;
        }
      });
    }
    //playerHeadIcon
  }

});
